package it.univpm.diiga.memorysim.kernel;
import java.util.ArrayList;
import java.util.Hashtable;

import it.univpm.diiga.memorysim.kernel.shared.Parameters;
import it.univpm.diiga.memorysim.kernel.shared.ProcessRequest;

public class SegPageTable implements IMemoryElement{
	
	private int PID;
	//private ArrayList<Integer[]> table;
	private int[][] table;
	
	private int start;
	private int end; 
	
	
	public SegPageTable(ProcessRequest processRequest, int dim){
		this.PID=processRequest.getPID();
		//int sizeTable=processRequest.getDimProcess()/Parameters.get.getDimBlock();
		//table=new ArrayList<Integer[]>();
		table=new int[dim][2];
	}

	
	public int getPID(){
		return this.PID;
		
	}
	
	public int[][] getTable(){
		return this.table;
		
	}
	
	public void writePaginRow(int row,int physicalAddress,int checkBit){
		this.table[row][0]=physicalAddress;
		this.table[row][1]=checkBit;
	}
	
	public void writeSegmRow(int row,int limit,int base){
		this.table[row][0]=limit;
		this.table[row][1]=base;
	}
	
	public int[] readRow(int row){
		return this.table[row];
	}
	
	public int readPhysicalAddress(int row){
		return this.table[row][0];
	}
	
	public int readCheckBit(int row){
		return this.table[row][1];
	}
	
	public int readLimit(int row){
		return this.table[row][0];
	}
	
	public int readBase(int row){
		return this.table[row][1];
	}
	
	public int getDim(){ //dimensione tabella
		return table.length;
	}
	
	
	// POSIZIONE TABELLA NELLA MEMORIA RISERVATA AL S.O.
	public void setStart(int start){
		this.start=start;
	}
	
	public void setEnd(int end){
		this.end=end;
	}
	
	public int getStart(){
		return start;
	}
	
	public int getEnd(){
		return end;
	}
	
	public boolean checkPage(int block){
		return this.table[block][1]==1;
	}


	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}
	
	
	
}
